package service

import (
	"github.com/gin-gonic/gin"
	"go-mvc-generator/code/dao"
	"go-mvc-generator/code/model"
)

var GetSysMenuService = new(SysMenuServiceImpl)

type ISysMenuService interface {
	GetById(ctx *gin.Context, id int) (sysMenu model.SysMenu)
	DelById(c *gin.Context, id int) bool
}

type SysMenuServiceImpl struct{}

func (s *SysMenuServiceImpl) GetById(ctx *gin.Context, id int) (sysMenu model.SysMenu) {
	model := dao.GetSysMenuDao.GetById(id)
	return model
}

func (s *SysMenuServiceImpl) DelById(c *gin.Context, id int) bool {
	del := dao.GetSysMenuDao.DelById(id)
	return del
}

func (s *SysMenuServiceImpl) Page(c *gin.Context, pageNum int, pageSize int, sysMenuQuery entity.SysMenuQuery) map[string]interface{} {
	list, total := dao.GetSysMenuDao.Page(pageNum, pageSize, sysMenuQuery)
	result := map[string]interface{}{
		"list":     list,
		"total":    total,
		"pageNum":  pageNum,
		"pageSize": pageSize,
	}
	return result
}
